// Created by WXX on 2021/11/4 9:24
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

/**
 * 执行用时：0 ms, 在所有 C++ 提交中击败了100.00%的用户
 * 内存消耗：5.9 MB, 在所有 C++ 提交中击败了20.53%的用户
 */
class Solution {
public:
    bool isPerfectSquare(int num) {
        int l = 1, r = num;
        while (l < r) {
            int mid = (r - l + 1) / 2 + l;
            if ((long long)mid * mid <= num) l = mid;
            else r = mid - 1;
        }
        return l * l == num;
    }
};

int main() {

    cout << Solution().isPerfectSquare(16) << endl;  // true
    cout << Solution().isPerfectSquare(14) << endl;  // false

    return 0;
}
